<template>
	<div class="sc_overview">
		<div class="overview_wrapper">
			<div class="item" v-for="(item, index) in tplOverviewList" :key="index">
				<div class="item-left">
					<div class="value">
						<div class="number">
							{{ item.number }}<span class="unit">{{ item.unit }}</span>
						</div>
						<div class="tips">+</div>
					</div>
					<div class="label">{{ item.label }}</div>
				</div>
				<img class="image" :src="item.url" alt="" />
			</div>
		</div>
	</div>
</template>
<script setup>
import { reactive, onMounted, getCurrentInstance, computed } from "vue"
import imgsList from "@/utils/images.js"
const { proxy } = getCurrentInstance()

let overviewData = reactive({})

const tplOverviewList = computed(() => {
	const data = [
		{ key: "schoolNumber", label: "直营小区", number: 0, url: imgsList.plot_icon },
		{ key: "teacherNumber", label: "教研团队", number: 0, url: imgsList.register_icon },
		{
			key: "abilityNumber",
			label: "美业人才",
			number: 0,
			unit: "W",
			url: imgsList.talents_icon
		},
		{
			key: "adviceNumber",
			label: "服务",
			number: 0,
			unit: "亿",
			url: imgsList.self_icon
		}
	]
	return data.map((item, index) => {
		return {
			...item,
			number: overviewData[item.key] ?? `10${index}`
		}
	})
})

onMounted(() => {
	getEnterpriseData()
})

const getEnterpriseData = async () => {
	const res = await proxy.$API.resources.enterpriseData.get()
	if (res.code === 200) {
		overviewData = res.data
	}
}
</script>
<style lang="scss" scoped>
.sc_overview {
	width: 100%;
	height: 106px;
	background: #ffffff;
	border: 1px solid #dbdde4;
	box-shadow: 0px 0px 120px 0px rgba(85, 120, 235, 0.1);
	border-radius: 4px;
	.overview_wrapper {
		height: 100%;
		display: flex;
		align-items: center;
		.item {
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: center;
			border-right: 1px solid #e6e6e6;
			&:last-child {
				border-right: none;
			}
			.image {
				width: 38px;
				height: 38px;
				margin-left: 24px;
			}
			.value {
				position: relative;
				.number {
					font-size: 42px;
					color: #333333;
					font-family: Arvo;
					line-height: 40px;
				}
				.tips {
					position: absolute;
					right: -12px;
					top: -4px;
					font-size: 20px;
					font-weight: 700;
				}
			}
			.label {
				font-size: 14px;
				font-weight: 400;
				color: #666666;
			}
		}
	}
}
</style>
